﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using BLL.RF.ATETest;
using Model.RF.ATETest;

public partial class ViewbyProduct_ViewTwoDimensionSN_ViewTwoDimensionSNbySN : System.Web.UI.Page
{
    TwoDimensionSN L5td;
    TwoDimensionSN_L13 L13td;

    public ViewbyProduct_ViewTwoDimensionSN_ViewTwoDimensionSNbySN()
    {
        L5td = new TwoDimensionSN();
        L13td = new TwoDimensionSN_L13();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        BindTwoDimensionSN();
    }

    private void BindTwoDimensionSN()
    {
        string var_packageProductSN = this.TextBox3.Text.Trim();
        this.TextBox1.Text = L5td.TwoDimensionSN_GetTDSNbySN(var_packageProductSN);

        //L5产品的数据绑定
        IList<TwoDimensionSNInfo> L5_list = L5td.TwoDimensionSN_GetbySN(var_packageProductSN);
        if (L5_list.Count>0 && L5_list[0].ProductTypeID.Equals("STR2400014", StringComparison.OrdinalIgnoreCase))
        {
            GridView1.DataSource = L5_list;
            GridView1.DataBind();
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                if (GridView1.Rows[i].Cells[6].Text == "Fail")
                    GridView1.Rows[i].Cells[6].ForeColor = System.Drawing.Color.Red;
            }
            GridView1.Visible = true;
            GridView2.Visible = false;
            return;
        }
        //L13产品的数据绑定
        IList<TwoDimensionSN_L13_Info> L13_list = L13td.TwoDimensionSN_L13_GetbySN(var_packageProductSN);
        if (L13_list.Count > 0 && L13_list[0].ProductTypeID.Equals("STR4400013", StringComparison.OrdinalIgnoreCase))
        {
            GridView2.DataSource = L13_list;
            GridView2.DataBind();
            for (int i = 0; i < GridView2.Rows.Count; i++)
            {
                if (GridView2.Rows[i].Cells[6].Text == "Fail")
                    GridView2.Rows[i].Cells[6].ForeColor = System.Drawing.Color.Red;
            }
            GridView2.Visible = true;
            GridView1.Visible = false;
            return;
        }
        //其它情况下不显示数据绑定控件
        else
        {
            GridView2.Visible = false;
            GridView1.Visible = false; 
        }
    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[7].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
    }

    protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[7].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
    }
}
